package com.xykj.common.handel;

import com.xykj.common.exception.BusinessException;
import com.xykj.common.response.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    private static final Logger log= LoggerFactory.getLogger(GlobalExceptionHandler.class);
    @ExceptionHandler(BusinessException.class)
    public Response handelBusiness(BusinessException e){
        log.error("出现异常，异常信息",e);
        return Response.error(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Response handelSystem(Exception e){
        log.error("出现异常，异常信息",e);
        return Response.error(e.getMessage());
    }
}
